package cn.hiapi.admin.api;

import cn.hiapi.admin.query.activity_order.AdminActivityExpandOrderQuery;
import cn.hiapi.admin.vo.ActivityInviteRecordVo;
import cn.hiapi.basic.controller.BasicQueryController;
import cn.hiapi.basic.service.BasicService;
import cn.hiapi.interfaces.DispatchContext;
import cn.hiapi.interfaces.user.IUserService;
import cn.hiapi.shopkeeper.entity.order.ActivityInviteRecord;
import cn.hiapi.shopkeeper.service.order.ActivityInviteRecordService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author AdinZ
 * @date 2023/2/16 16:13
 */
@RestController
@RequestMapping("/manage/activity/invite-record")
public class AdminActivityInviteRecordController extends BasicQueryController<ActivityInviteRecord,Long,ActivityInviteRecordVo, AdminActivityExpandOrderQuery> {

    protected AdminActivityInviteRecordController(ActivityInviteRecordService basicService, DispatchContext dispatchContext) {
        super(basicService, dispatchContext);
    }

    @Override
    public List<ActivityInviteRecordVo> toListVo(List<ActivityInviteRecord> list, String[] fields) {
        return this.toList(list,fields);
    }

    @Override
    public ActivityInviteRecordVo toData(ActivityInviteRecord data, String[] fields) {
        ActivityInviteRecordVo vo = data.copy(new ActivityInviteRecordVo());
        vo.setInviteUser(this.dispatchContext.getServiceOne(IUserService.class).fieldBase(vo.getInviteUid()));
        vo.setUser(this.dispatchContext.getServiceOne(IUserService.class).fieldBase(vo.getUid()));
        return vo;
    }
}
